package com.linkhub.oms.data.sync.api.shopify.client;

import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;
import com.linkhub.oms.data.sync.api.shopify.domain.request.FulfillmentRequest;
import com.linkhub.oms.data.sync.api.shopify.domain.response.FulfillmentOrderResponse;
import com.linkhub.oms.data.sync.api.shopify.domain.response.FulfillmentResponse;
import com.linkhub.oms.data.sync.api.shopify.domain.response.ShopOrderResponse;
import com.linkhub.oms.data.sync.api.shopify.domain.response.ShopifyCountResponse;

import static com.linkhub.oms.common.constant.ShopifyConstant.ACCESS_TOKEN_HEADER;

/**
 * @Description: OrderClient
 * @Author: echo
 * @Date: 2024/3/29 16:10
 * @Version: 1.0
 */
public interface OrderClient {
    @Get("{shop_url}/admin/api/2024-01/orders.json?fields={fields}&limit={limit}&updated_at_min={updated_at_min}&status=any")
    @LogEnabled(logResponseContent = false)
    ForestResponse<ShopOrderResponse> listAfterUpdateAtOrders( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                               @Var("shop_url") String shopUrl,
                                                               @Var("fields") String fields,
                                                               @Var("updated_at_min") String updatedAtMin,
                                                               @Var("limit") Integer limit );


    @Get("{shop_url}/admin/api/2024-01/orders/count.json?updated_at_min={updated_at_min}")
    ForestResponse<ShopifyCountResponse> getAfterUpdateAtOrderCount( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                                     @Var("shop_url") String shopUrl,
                                                                     @Var("updated_at_min") String updatedAtMin );


    @Get("{shop_url}/admin/api/2024-01/orders/count.json")
    ForestResponse<ShopifyCountResponse> getOrderCount( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                        @Var("shop_url") String shopUrl );


    @Get("{shop_url}/admin/api/2024-01/orders.json?fields={fields}&ids={ids}")
    ForestResponse<ShopOrderResponse> listOrderLatestUpdateAtByIds( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                                    @Var("shop_url") String shopUrl,
                                                                    @Var("fields") String fields,
                                                                    @Var("ids") String ids );

    @Get("{shop_url}/admin/api/2024-01/orders/{order_id}/fulfillment_orders.json")
    ForestResponse<FulfillmentOrderResponse> fulfillmentOrders( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                                @Var("shop_url") String shopUrl,
                                                                @Var("order_id") String orderId );

    @Post(value = "{shop_url}/admin/api/2024-01/fulfillments.json",
            dataType = "json")
    ForestResponse<FulfillmentResponse> fulfillments( @Header(ACCESS_TOKEN_HEADER) String accessToken,
                                                      @Var("shop_url") String shopUrl,
                                                      @JSONBody FulfillmentRequest request );
}
